
function getList() {
    let ParseMenu_id = ''
    const menu_id = localStorage.getItem('LAST_IFRAME')
    if (menu_id && menu_id !== '') {
        try {
            const JSONData = JSON.parse(menu_id)
            if (JSONData && JSONData.menu_id) {
                ParseMenu_id = JSONData.menu_id
            }

        } catch (err) {
            console.log(err)
        }
    }
    console.log(menu_id)
    commonAjax({
        type: 'GET',
        url: baseURL + '/api/m' + member_id + '/67d0e3b433f73',
        data: {
            menu_id: ParseMenu_id
        },
        dataType: 'json',
        async: false,
        success: (res) => {
            if (res.code != 1) {
                this.$message.info(res.msg);
                return;
            }
            if (!res.data || res.data.length === 0) {
                return this.$message.info('暂无数据');
            }
            console.log(res.data)
            this.DataList = res.data
        }
    });
},
function GPT(q) {
    const data = JSON.stringify({
        "inputs": {},
        "query": "心理学入门书籍有哪些推荐",
        "response_mode": "streaming",
        "conversation_id": "",
        "user": "user_7049",
        "aid": this.token,
        "uri": "m7049/67d0e4a56d19f "
    });
    const xhr = new XMLHttpRequest();
    let buffer = "";
    let str = ''

    xhr.open(
        "POST",
        "https://tyrz.zhuaizhuaiyu.com/chat"
    );
    xhr.responseType = 'text';
    xhr.setRequestHeader("Content-Type", "application/json");

    xhr.onprogress = e => {
        if (xhr.responseText) {
            const newData = xhr.responseText.slice(buffer.length);
            buffer = xhr.responseText;
            const lines = newData.split("\n");
            lines.forEach(line => {
                if (line.startsWith('data: ')) {
                    try {
                        const data = JSON.parse(line.slice(6));
                        console.log('data', data);
                        if (data.answer) {
                            str += data.answer;
                            // 问答的数组
                            this.qaCollection = this.qaCollection.map(item => {
                                if (item.aid == this.CurrentActiveIndex) {
                                    const tempDiv = document.createElement('div');
                                    tempDiv.innerHTML = marked(str);
                                    let processedHtml = str.replace(
                                        /<think>([\s\S]*?)(<\/think>|$)/g,
                                        (match, p1) => {
                                            const content = marked(p1.replace(/<\/?think>/g, ''));
                                            return `<div style="color:#8b8b8b !important;all:initial;font-family:inherit;line-height:24px;margin-bottom:14px">${content}</div>`;
                                        }
                                    );
                                    item.answer = marked(processedHtml);
                                }
                                return item
                            })
                        }
                    } catch (e) {
                        console.log(e);
                    }
                }
            });
        }
    };
    xhr.onreadystatechange = () => {
        if (xhr.readyState === 4) {
            if (xhr.status === 200) {
                this.loading = false

            } else {
                console.log(xhr.status)
            }
        }
    };
    xhr.send(data);

},
